﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Customers;

namespace PMS.Data.EntityMap.Customers
{
    /// <summary>
    /// Represents a Customer mapping configuration
    /// </summary>
    public partial class CustomerMap : PMSEntityTypeConfiguration<Customer>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<Customer> builder)
        {
            builder.ToTable("bus_customer");
            builder.HasKey(customer => customer.Id);

            builder.Property(customer => customer.CustomerGuid).IsRequired();
            builder.Property(customer => customer.LoginName).HasMaxLength(32).IsRequired();
            builder.Property(customer => customer.Mobile).HasMaxLength(32).IsRequired();
            builder.Property(customer => customer.Email).HasMaxLength(128).IsRequired();
            builder.Property(customer => customer.NickName).HasMaxLength(64);
            builder.Property(customer => customer.EmailToRevalidate).HasMaxLength(128);
            builder.Property(customer => customer.LastLoginIpAddress).HasMaxLength(64).IsRequired();
            builder.Property(customer => customer.RegisteredInStoreId).IsRequired();
            builder.Property(customer => customer.IsDeleted).IsRequired();
            builder.Property(customer => customer.IsActive).IsRequired();
            base.Configure(builder);
        }

        #endregion
    }
}
